<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="jquery-3.5.0.js"></script>
    </head>
    <body>
        <div id="result"></div>
        <img src="" width="60%">
        <input type="file" id="file" >
        <input type="button" value="上传" onclick="uploadFile()">

    <script>
        function uploadFile() {
            var file = $("#file")[0].files[0];
            var formData = new FormData();
            formData.append("file",file);
            $.ajax({
                type:'post',
                url:'/upload',
                processData: false,
                contentType: false,
                data: formData,
                success: function (msg) {
                    $("#result").html(msg)
                    $("img").attr("src",msg)
                }
            })
        }
    </script>
    </body>

</html>